﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>新建分组</title>
     <!-- 引用配置文件.-->
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/CommonUnite.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {

            var gfID = GetQueryString("GroupField");
            if (gfID == null) {
                gfID = "0";
                $("#Button4").hide();
            }

            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=GroupField_Init&GroupField=" + gfID + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {
                    if (data.indexOf('err@') >= 0) {
                        $("#Msg").html("<font color=red>" + data + "</font>");
                        return;
                    }

                    data = JSON.parse(data);
                    if (data instanceof Array) { //判断是否是数组 如果是数组就取第一个对象 杨玉慧
                        data = data[0];
                    }
                    $("#TB_Blank_Name").val(data.Lab);
                    $("#TB_Blank_No").val(data.CtrlID);
                    return;
                }
            });
        });

        //转拼音，并去除开头为数字的字符
        function ParseStringToPinYin(parseString, parseModel) {
            parseString = $.trim(parseString);
            if (parseString != "") {
                $.post(Handler, { action: 'ParseStringToPinyin', name: parseString, flag: parseModel }, function (data) {
                    if (data != "false") {
                        document.getElementById("TB_No").value = data;
                    }
                });
            }
        }


        //传入父窗体
        function GetFrmInfo() {
            return {
                Name: $.trim($("#TB_Name").val()),
                No: $.trim($("#TB_No").val()),
                IsCreateLabel: $("#CB_SCBQ").prop("checked")
            };
        }

        function SaveBlank() {

            var name = $("#TB_Blank_Name").val();

            if (name == "") {
                alert("分组名称不能为空.");
                return;
            }

            var fk_mapData = GetQueryString("FK_MapData");
            var checkBoxIDs = GenerCheckIDs(); //获得所有的 checkBox ID传入到后台去,用于解决checkbox控件，在没有被选择的时候，没有值的问题。
            var frmData = $("#cc").serialize();

            $("#Msg").html("正在保存,请稍后......");
            var gfID = GetQueryString("GroupField");
            if (gfID == null)
                gfID = "0";

            $.ajax({
                data: frmData,
                type: 'post',
                async: true,
                url: Handler + "?DoType=GroupField_SaveBlank&CheckBoxIDs=" + checkBoxIDs + "&GroupField=" + gfID + "&FK_MapData=" + fk_mapData + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {

                    if (data.indexOf('err@') >= 0) {
                        $("#Msg").html("<font color=red>" + data + "</font>");
                        return;
                    }

                    $("#Msg").html("<font color=green >" + data + " , 请关闭窗口.</font>");
                    window.close();
                    return;
                }
            });
        }

        function EditBlank() {

            var fk_mapData = GetQueryString("FK_MapData");
            var gfID = GetQueryString("GroupField");
            if (gfID == null)
                gfID = "0";
            //var url = "GroupFieldEdit.htm?GroupField=" + gfID + "&FK_MapData=" + fk_mapData + "&m=" + Math.random();

            var url = "../../Comm/En.htm?EnName=BP.Sys.GroupField&PKVal=" + gfID;

            window.showModalDialog(url, "", "dialogWidth=600px;dialogHeight=300px;dialogLeft=560px;dialogTop=300px;");
            //window.location.href = url;

        }

        function SaveCheck() {

            var fk_mapData = GetQueryString("FK_MapData");
            var checkBoxIDs = GenerCheckIDs();
            var frmData = $("#cc").serialize();

            $.ajax({
                data: frmData,
                type: 'post',
                async: true,
                url: Handler + "?DoType=GroupField_Save&FK_MapData=" + fk_mapData,
                dataType: 'html',
                success: function (data) {
                    if (data.indexOf('err@') >= 0) {
                        $("#Msg").html("<font color=red>" + data + "</font>");
                        return;
                    }

                    alert(data + '\t\n 如果父页面不能刷新，请关闭当前表单设计器重新打开.');
                    window.parent.location.href = window.parent.location.href;
                }
            });


        }
        
    </script>

</head>
<body>

<div id="Msg"></div>


<form id="cc">

 <fieldset>
    <legend>新建空白分组</legend>
    <table>
    <tr> 
    <td>分组名称(不能为空)</td>
    <td>  <input type="text" value="" name="TB_Blank_Name" id="TB_Blank_Name" />  </td>
    </tr>

    <tr> 
    <td>分组标记(不能为空,必须以英文开头)</td>
    <td>  <input type="text" value="" name="TB_Blank_No" id="TB_Blank_No" />   </td>
    </tr>

    <tr>
    <td colspan="4"> 
     <input type="button" value="保存"   onclick="SaveBlank()" id="Btn_SaveBlank" name="Btn_SaveBlank" />
    <input type="button" value="编辑"   onclick="EditBlank()" id="Button4" name="Btn_SaveBlank" />
    <font color="gray"> 空白字段分组，建立后可以把相关的字段放入此分组里。</font></td>
    </tr>
     
    </table>
    </fieldset>


    <!--
 <fieldset>
    <legend>新建审核分组</legend>
    <table>
    <tr> 
    <td>分组名称</td>
    <td>  <input type="text" value="" name="TB_Check_Name" id="TB_Check_Name" />  </td>
    </tr>

    <tr> 
    <td>前缀</td>
    <td>  <input type="text" value="" name="TB_Check_No" id="TB_Check_No" />   </td>
    </tr>

    <tr>
    <td colspan="4"> <font color="gray"> 审核分组：同时创建 _Checker, _CheckRDT, _CheckNote 三个字段.</font></td>
    </tr>

    <tr> 
    <td colspan="4" > 
    <input type="button" value="保存"   onclick="SaveCheck()" id="Btn_SaveCheck" name="Btn_SaveCheck" />
     </td>
    </tr>
    </table>
    </fieldset>
     

    <fieldset>
    <legend> <a href="GroupField.htm?DoType=NewEvalGroup&FK_MapData=<%=this.FK_MapData %>" > 创建工作质量考核字段分组</a></legend>
     
     <ul>
      <li> 创建质量考核: EvalEmpNo,EvalEmpName,EvalCent,EvalNote 4个必要的字段。</li>
     </ul>
    </fieldset>-->

    </form>

</body>
</html>
